﻿Imports CustomTshirtFinal

Public Class Login
  
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim negocio As New UsuarioNegocio

        Try
            Dim modelo = negocio.logear(Me.txtCorreo.Text, Me.txtPass.Text)
            MessageBox.Show("Welcome " + Me.txtCorreo.Text, "WELCOME")
            Dim mdi As Menu = New Menu
            mdi.Show()
            Me.Visible = False

        Catch ex As Exception
            Me.txtCorreo.Text = ""
            Me.txtPass.Text = ""
            MsgBox("El correo y/o clave son incorrectos")
            
        End Try
        If CheckBox1.Checked = True Then
            My.Settings.ChkMail = True
            My.Settings.StrMail = txtCorreo.Text

        Else

            My.Settings.ChkMail = False
            My.Settings.StrMail = ""

        End If

        If CheckBox2.Checked = True Then

            My.Settings.ChkPass = True
            My.Settings.StrPass = txtPass.Text

        Else

            My.Settings.ChkPass = False
            My.Settings.StrPass = ""

        End If

        My.Settings.Save()
        My.Settings.Reload()


    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub Login_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        If My.Settings.ChkMail = True Then

            txtCorreo.Text = My.Settings.StrMail
            CheckBox1.Checked = True

        Else

            txtCorreo.Text = ""
            CheckBox1.Checked = False

        End If

        If My.Settings.ChkPass = True Then

            txtPass.Text = My.Settings.StrPass
            CheckBox2.Checked = True

        Else

            txtPass.Text = ""
            CheckBox2.Checked = False

        End If

    End Sub
End Class
